//
//  ShellRechargeCell.m
//  ShellWallert
//
//  Created by lvzhao on 2019/9/27.
//  Copyright © 2019年 VV. All rights reserved.
//

#import "ShellRechargeCell.h"
#import "ShellWallertModel.h"


@interface ShellRechargeCell()

//数量
@property (nonatomic,strong) UILabel *numberLabel;

//状态
@property (nonatomic,strong) UILabel *statusLabel;

//时间
@property (nonatomic,strong) UILabel *timeLabel;

@end

@implementation ShellRechargeCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
    }
    return self;
}


#pragma mark - setupView
- (void)setupView{
    
    //数量
    [self.contentView addSubview:self.numberLabel];
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(15);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(self.contentView);
    }];
    
    //状态
    [self.contentView addSubview:self.statusLabel];
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(100);
        make.width.mas_equalTo(90);
        make.height.mas_equalTo(self.contentView);
    }];

    
    //时间
    [self.contentView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(200);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(self.contentView);
    }];
    
}


#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (void)setModelObject:(id)modelObject{
    ShellWallertModel *wallertModel = modelObject;
    self.numberLabel.textColor = UIColorHex(0x80C35F);

    if(self.indexPath.row % 2 == 0){
        self.backgroundColor = COLOR_BACKGROUND;
    } else {
        self.backgroundColor = UIColorHex(0x031D32);
    }
    
    NSString *operateAmount = [NSString stringWithFormat:@"+%@",wallertModel.operateAmount].saveDecimal;
    NSInteger status = [wallertModel.status integerValue];
    NSString *statusString = @"";
      switch (status) {
          case 10:
          case 20:
          case 21:
              statusString = LZLocalizedString(@"区块确认中");
              break;
          case 30:
              statusString = LZLocalizedString(@"成功");
          break;
          case 40:
              statusString = LZLocalizedString(@"失败");
          break;
          default:
              break;
      }
    self.numberLabel.text = operateAmount;
    self.statusLabel.text = statusString;
    self.timeLabel.text = wallertModel.createTime;
}


//货币
- (UILabel *)numberLabel{
    if(!_numberLabel){
        _numberLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _numberLabel;
}

//状态
- (UILabel *)statusLabel{
    if(!_statusLabel){
        _statusLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _statusLabel;
}

//时间
- (UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0x678DA8) font:k_textFont(13)];
        [_timeLabel lz_centerAlignment];
    }
    return _timeLabel;
}


@end
